package com.ruoyi.bean.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.domain.bo.SysTenantBo;
import com.ruoyi.domain.entity.SysTenant;
import com.ruoyi.domain.vo.SysTenantVo;
import com.ruoyi.mapper.SysTenantMapper;
import io.github.stylesmile.annotation.AutoWired;
import io.github.stylesmile.annotation.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author cy
 */
@Service
public class TenantService {
    @AutoWired
    SysTenantMapper sysTenantMapper;

    public List<SysTenantVo> queryList(SysTenantBo bo) {
//        SysTenant sysTenant = SysTenant.

        QueryWrapper<SysTenant> lqw = Wrappers.query();
        List<SysTenant> sysTenantList = sysTenantMapper.selectList(lqw);
        List<SysTenantVo> sysTenantVos = sysTenantList.stream().map(sysTenant -> {
            return SysTenantVo.builder()
                    .id(sysTenant.getId())
                    .address(sysTenant.getAddress())
                    .intro(sysTenant.getIntro())
                    .tenantId(sysTenant.getTenantId())
                    .accountCount(sysTenant.getAccountCount())
                    .companyName(sysTenant.getCompanyName())
                    .contactPhone(sysTenant.getContactPhone())
                    .contactUserName(sysTenant.getContactUserName())
                    .licenseNumber(sysTenant.getLicenseNumber())
                    .remark(sysTenant.getRemark())
                    .status(sysTenant.getStatus())
                    .expireTime(sysTenant.getExpireTime())
                    .packageId(sysTenant.getPackageId())
                    .build();
        }).collect(Collectors.toList());
        return sysTenantVos;
    }
}
